﻿using System;
using System.Collections.Generic;
using System.Web;

namespace WeiboFilter
{
    public enum Months
    {
        Jan = 1,
        Feb,
        Mar,
        Apr,
        May,
        Jun,
        Jul,
        Aug,
        Sep,
        Oct,
        Nov,
        Dec
    }

    public class CommanHelper
    {
        private CommanHelper() { }
        /// <summary>
        /// 将微博时间转换为数字形式时间 
        /// </summary>
        /// <param name="weiboDate">"Tue Nov 30 15:36:28 +0800 2010"</param>
        /// <returns>"201101081427"</returns>
        public static string ParseDateTime(string weiboDate)
        {
            //e.g. "Tue Nov 30 15:36:28 +0800 2010";
            string[] slices = weiboDate.Split(' ');
            string[] time = slices[3].Split(':');


            string formattedDatetime = string.Format("{0}{1:D2}{2:D2}{3:D2}{4:D2}", slices[5], (int)(Months)Enum.Parse(typeof(Months), slices[1]),
                slices[2], time[0], time[1]);
            return formattedDatetime;
            //"201101081427"
        }

    }
}